Skip to content

Adjust code according to review #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 26, 2018

Conversation

fredericDelaporte
Copy link

@fredericDelaporte fredericDelaporte commented Apr 25, 2018

Partially address the review of nhibernate#1662.

This increases the number of failing tests. I consider these failing tests need more investigation and another handling than considering some feature not supported while they look indeed to be supported (see review details).

<property name="connection.connection_string">
Server=localhost:39015;UserID=nhibernate;Password=
Server=localhost:39015;UserID=nhibernate;Password=;
Enlist=false;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the way to fix most transaction scope tests failures in my opinion. So this needs to be adjusted in any previously existing test configuration.

default:
Assert.That(substringFunction, Is.TypeOf<AnsiSubstringFunction>());
break;
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than adding one more if, I have made use of the new pattern matching switch.

@@ -18,7 +18,7 @@ protected override string MappingsAssembly

protected override bool AppliesTo(Dialect.Dialect dialect)
{
return dialect.SupportsSequences && !(dialect is Dialect.MsSql2012Dialect) && !(dialect is Dialect.AbstractHanaDialect);
return dialect.SupportsSequences && !(dialect is Dialect.MsSql2012Dialect) && !(dialect is Dialect.HanaDialectBase);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still remains the question here:

Is there no way to provide a proper Dialect.AddIdentifierOutParameterToInsert override for supporting this? (I think the MsSql2012Dialect is just lacking it here, and should have it indeed. Better not add another case where the override would be just missing.)

If there is no solution, please add a comment for telling why HANA is excluded, like "SAP HANA does not support a syntax allowing to return the inserted id as an output parameter or a return value".

if (Dialect is AbstractHanaDialect)
{
Assert.Ignore("feature not supported: Currently specify table name by 'FOR UPDATE of t1.c1' if there are more than one tables/views/subqueries in the FROM clause");
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this does not cause any failure in my tests. Was it failing in some earlier version of the dialect, but you would have fix that then forgot about the test change here?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new with HANA 2 SP3. I wrote the dialect for HANA 2 SP2 where it's failing. But I think it's ok to require a minimum of HANA 2 SP3 for NHibernate.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, considering this does not change anything in the NHibernate assembly, this will be a requirement only for the test assembly. So yes, let the tests have this requirement.

@@ -8,8 +8,7 @@ public class Fixture : BugTestCase
{
protected override bool AppliesTo(Dialect.Dialect dialect)
{
return !(dialect is Oracle8iDialect) &&
!(dialect is AbstractHanaDialect);
return !(dialect is Oracle8iDialect);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not fail on my side too. Am I missing something?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably excluded the test at first before I implemented the boolean operators and forgot to include it again afterwards.

@@ -9,8 +9,7 @@ public class Fixture : BugTestCase
{
protected override bool AppliesTo(Dialect.Dialect dialect)
{
return !(dialect is Oracle8iDialect) &&
!(dialect is AbstractHanaDialect);
return !(dialect is Oracle8iDialect);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous comment.

connectionString, $"[^;\"a-zA-Z]*{autoEnlistmentKeywordPattern}=[^;\"]*;?", string.Empty,
RegexOptions.IgnoreCase);
// Avoid redundant semi-colon
connectionString = Regex.Replace(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HanaConnection does not support them, so I had to improve this connection string patching.

@@ -182,7 +182,6 @@ public void ShouldNotifyAfterDistributedTransactionWithOwnConnection(bool doComm
{
using (var tx = new TransactionScope())
{
ownConnection1.EnlistTransaction(System.Transactions.Transaction.Current);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was undue. The enlistment is done by NHibernate even on provided connections. (When I have worked on the system transaction mess (see NH-4011), I have initially considered not handling transaction enlistment on provided connections, but changed my mind later and forgot about this line here.)

Due to HanaConnection not supporting being asked to enlist in a transaction in which it is already enlisted, the test was failing for HANA.

@fredericDelaporte fredericDelaporte changed the title Asjust code according to review Adjust code according to review Apr 26, 2018
Partially address the review.
Do some more reformatting, fix some more tab/spaces mixup.
@fredericDelaporte
Copy link
Author

If merging this, many things to address will remain:

  • Implementation questions:
    • Should Dialect.AddIdentifierOutParameterToInsert be implemented on HanaDialectBase?
    • Should SupportsMultipleOpenReaders be overridden to false? Normally there are some test which would failed if this was not supported and overridden to false, especially those using multiple calls to IQuery.Enumerable without disposing them (which is a bit tricky to determine, because their implementation causes foreach loop to dispose them).
  • Failing tests to investigate:
    • Insertordering.FamilyModel.Fixture.CircularReferences
    • Legacy.FooBarTest:
      • CollectionsInSelect
      • FindByCriteria
      • UpdateFromTransient
    • Linq:
      • OrderByTests:
        • AggregateAscendingOrderByClause
        • AggregateDescendingOrderByClause
        • OrderByCalculatedAggregatedSubselectProperty
        • OrderByWithSelfReferencedSubquery1
        • OrderByWithSelfReferencedSubquery2
      • PropertyMethodMappingTests.CanExecuteCountInSelectClause
      • SelectionTests.CanSelectWithAggregateSubQuery
      • WhereSubqueryTests:
        • ProductsWithSubqueryReturningBoolFirstOrDefaultEq
        • ProductsWithSubqueryReturningStringFirstOrDefaultEq
        • SubqueryWhereFailingTest
        • SubqueryWhereFailingTest2
        • SubqueryWhereFailingTest3
        • SubselectCanHaveBoolResult
    • NH1394:
      • CanOrderBySubqueryProjection
      • CanOrderBySubqueryProjectionDesc
    • NH2192.HqlIsThreadsafe_UsingThreads
    • NH2244.LinqComponentTypeEquality
    • NH2394.LinqUserTypeEquality
    • NH2760:
      • ShouldBeAbleToSelectUserGroupAndOrderByUserCount
      • ShouldBeAbleToSelectUserGroupAndOrderByUserCountWithHql
    • NH280.ConstInSelect
    • NH3414:
      • OrderByMultipleQuery
      • OrderBySingleQueryComplex
      • OrderBySingleQueryComplexReverse
      • OrderBySingleQueryTest
    • Properties:
      • CompositePropertyRefTest
      • DynamicEntityTest

Some of them should be easy to "fix", their error being quite self-explanatory: "correlated subquery cannot have TOP or ORDER BY". Each case I have seen had a top, so adding a TestDialect.SupportsTopInCorrelatedSubquery property should allow to handle those tests. Other needs more investigations.

@fredericDelaporte
Copy link
Author

Other cases of failing scalar sub-selects seems to always be "scalar sub select in order by", so a TestDialect.SupportsScalarSubSelectsInOrderBy property could be added for handling them too. This one really looks like a HANA bug.

@breglerj breglerj merged commit 8f65834 into breglerj:nhibernatehanasupport Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants